#!/bin/sh
####################################
#
# Backup to NFS mount script.
#
####################################

projectName=$1
scriptsDir=$projectName/script
cssDir=$projectName/style
libDir=$projectName/lib
imageDir=$projectName/img

echo creating project $projectName
echo creating required directories

# mkdir $projectName;
mkdir $scriptsDir;
mkdir $cssDir;
mkdir $libDir;
mkdir $imageDir;

echo creating template files

touch $projectName/manifest.json
touch $projectName/options.html
touch $projectName/background.html
touch $scriptsDir/func.js
touch $scriptsDir/entry.js
touch $cssDir/default.js
wget -q --progress=dot --directory-prefix=$libDir http://code.jquery.com/jquery-1.4.2.js

echo generating default content
cd $projectName

# manifest

echo "{" >> manifest.json
echo "  \"name\": \"$projectName\"," >> manifest.json
echo "  \"version\": \"1.0\"," >> manifest.json
echo "  \"description\": \"$projectName project\"," >> manifest.json
echo "  \"background_page\": \"background.html\"," >> manifest.json
echo "  \"options_page\": \"options.html\"," >> manifest.json
echo "  \"browser_action\": {" >> manifest.json
echo "      \"name\": \"$projectName\"," >> manifest.json
echo "      \"default_icon\": \"img/\", " >> manifest.json
echo "      \"default_title\": \"$projectName\"," >> manifest.json
echo "      \"popup\" : \"options.html\"" >> manifest.json
echo "  }," >> manifest.json
echo "  \"content_scripts\": [" >> manifest.json
echo "    {" >> manifest.json
echo "      \"matches\": [\"\"]," >> manifest.json
echo "      \"css\": [\"style/default.css\"]," >> manifest.json
echo "      \"js\": [\"lib/jquery-1.4.2.js\", \"script/entry.js\", \"script/func.js\"]," >> manifest.json
echo "	  \"run_at\": \"document_end\"," >> manifest.json
echo "	  \"all_frames\": true" >> manifest.json
echo "    }" >> manifest.json
echo "  ]" >> manifest.json
echo "}" >> manifest.json

# background

echo "<html>" >> background.html
echo "<head>" >> background.html
echo "<script language=\"JavaScript\" type=\"text/javascript\">" >> background.html
echo "" >> background.html
echo "</script>" >> background.html
echo "</head>" >> background.html
echo "</html>" >> background.html

# options

echo "<html>" >> options.html
echo "<head>" >> options.html
echo "	<script type=\"text/javascript\" src=\"lib/jquery-1.4.2.js\"></script>" >> options.html
echo "	<script type=\"text/javascript\" src=\"script/func.js\"></script>" >> options.html
echo "</head>" >> options.html
echo "<body>" >> options.html
echo "</body>" >> options.html
echo "</html>" >> options.html

echo finish



